﻿@model IEnumerable<OnlineBookstore.Models.BookDetailsInfo>

@{
    Layout = null;
    // 添加分页相关变量
    int currentPage = ViewBag.CurrentPage ?? 1;
    int totalPages = ViewBag.TotalPages ?? 1;
    int pageSize = ViewBag.PageSize ?? 10;
}

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>书籍管理 - 网上书城</title>
    <link rel="stylesheet" href="~/conjs/global.css" />
    <link rel="stylesheet" href="~/conjs/Site.css" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #ecf0f1;
            --accent-color: #e74c3c;
            --text-color: #34495e;
        }

        body {
            font-family: 'Segoe UI', system-ui, sans-serif;
            background: #f8f9fa;
        }

        /* 页眉样式 */
        #header {
            background: var(--primary-color);
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        #logotxt {
            color: white;
            font-size: 1.8rem;
            font-weight: 600;
        }

        /* 导航菜单 */
        #menu {
            background: white;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            padding: 1rem 2rem;
        }

            #menu ul {
                display: flex;
                gap: 2rem;
                margin: 0;
                padding: 0;
            }

            #menu li {
                list-style: none;
            }

            #menu a {
                color: var(--text-color);
                text-decoration: none;
                padding: 0.5rem 1rem;
                border-radius: 4px;
                transition: all 0.3s ease;
            }

                #menu a:hover {
                    background: var(--secondary-color);
                }
        /* 分页容器 */
        .pagination-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 20px 0;
            padding: 10px 0;
        }

        /* 分页信息 */
        .pagination-info {
            color: #666;
            font-size: 14px;
        }

        /* 分页链接 */
        .pagination {
            display: flex;
            gap: 5px;
        }

        .page-link {
            display: inline-block;
            padding: 5px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            color: #333;
            text-decoration: none;
            transition: all 0.3s;
        }

            .page-link:hover:not(.disabled):not(.active) {
                background-color: #f5f5f5;
            }

            .page-link.active {
                background-color: #007bff;
                color: white;
                border-color: #007bff;
            }

            .page-link.disabled {
                color: #ccc;
                cursor: not-allowed;
            }

            .page-link.first, .page-link.last, .page-link.prev, .page-link.next {
                padding: 5px 10px;
            }
        /* 主要内容 */
        #content {
            padding: 2rem;
            width: 80%;
            margin: 0 auto;
            position:relative;
        }

        .dashboard-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
        }

        .dashboard-title {
            color: var(--primary-color);
            font-size: 1.8rem;
        }

        /* 书籍卡片 */
        .book-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 3fr));
            gap: 1.5rem;
        }

        .book-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 3px 6px rgba(0,0,0,0.1);
            overflow: hidden;
            transition: transform 0.3s ease;
        }

            .book-card:hover {
                transform: translateY(-5px);
            }

        .book-cover {
            width: 100%;
            height: 250px;
            object-fit: cover;
            border-bottom: 2px solid var(--secondary-color);
        }

        .book-content {
            padding: 1.5rem;
        }

        .book-meta {
            margin: 0.5rem 0;
            color: #7f8c8d;
            font-size: 0.9rem;
        }

        .book-code {
            color: var(--accent-color);
            font-weight: 600;
        }

        .book-actions {
            display: flex;
            gap: 0.5rem;
            margin-top: 1.5rem;
            flex-wrap: wrap;
        }

        .action-btn {
            padding: 0.5rem 1rem;
            border-radius: 20px;
            text-decoration: none;
            font-size: 0.9rem;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .edit-btn {
            background: #3498db;
            color: white;
        }

        .add-btn {
            background: #2ecc71;
            color: white;
        }

        .detail-btn {
            background: #9b59b6;
            color: white;
        }

        .delete-btn {
            background: #e74c3c;
            color: white;
        }

        /* 页脚 */
    

        @@media (max-width: 768px) {
            .book-grid {
                grid-template-columns: 1fr;
            }
        }
        /* 导航样式 */
        .nav {
            background-color: #34495e;
            padding: 10px 0;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

            .nav ul {
                list-style: none;
                padding: 0;
                margin: 0;
                display: flex;
                justify-content: center;
                flex-wrap: wrap;
                gap: 20px;
            }

            .nav li a {
                color: white;
                text-decoration: none;
                padding: 5px 10px;
                border-radius: 4px;
                transition: all 0.3s ease;
                font-size: 14px;
            }

                .nav li a:hover {
                    background-color: rgba(255,255,255,0.1);
                    text-decoration: underline;
                }

        .book-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1.5rem;
            width: 100%;
            margin: 0;
            padding: 0;
        }

        .book-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 3px 6px rgba(0,0,0,0.1);
            overflow: hidden;
            transition: transform 0.3s ease;
            height: 100%; /* 确保卡片高度填满 */
            display: flex;
            flex-direction: column;
        }

        /* 确保内容区域也填满 */
        .book-content {
            flex: 1;
            display: flex;
            flex-direction: column;
        }
        .head {
            background-color: lightskyblue;
            border-radius: 20px;
            text-decoration: none;
            font-size: 0.9rem;
            transition: all 0.3s ease;
            align-items: center;
        }
        .book-actions {
            margin-top: auto; /* 将操作按钮推到卡片底部 */
        }
        #footer {
            background: var(--primary-color);
            color: white;
            text-align: center;
            padding: 1.5rem;
            margin-top: 3rem;
            width: 100%;
            height: 100px;
            /* footer的高度一定要是固定值*/
            position: relative;
            bottom: 0px;
        }
    </style>
</head>
<body>
    <div id="all">
        <!-- 页眉 -->
        <div id="header">
            <div id="logo"><span id="logotxt">广软智慧书城</span></div>
            <div id="loginmsg">
                @Html.ActionLink("退出", "Index", "ShopInfo", null, new { @class = "action-btn", style = "background: var(--accent-color);" })
            </div>
        </div>

        <!-- 导航菜单 -->
        <nav class="nav">
            <div class="container">
                <ul>
                    <li><a href="/OrderInfo/Index">订单设置</a></li>
                    <li><a href="/CapitalAdvanc/Index">客户账户设置</a></li>
                    <li class="head"><a href="/BookDetailsInfo/GetBookList">书籍设置</a></li>
                    <li><a href="/ShopInfo/GetShopList">客户设置</a></li>
                    <li><a href="/AdministrationInfo/GetAdmin">管理员设置</a></li>
                </ul>
            </div>
        </nav>

        <!-- 主要内容 -->
        <div id="content">
            <div class="dashboard-header">
                <h1 class="dashboard-title"><i class="fas fa-book-open"></i> 书籍管理</h1>
                @Html.ActionLink("添加新书", "Create", "BookDetailsInfo", new { area = "Admin" }, new { @class = "action-btn add-btn" })
            </div>


            <div class="book-grid">
                @foreach (var item in Model)
                {
                    <div class="book-card">
                        <img src="@item.Bookcover" class="book-cover" alt="@item.BookName 封面">
                        <div class="book-content">
                            <div class="book-meta book-code">#@item.BookCode</div>
                            <h3 class="book-title">@item.BookName</h3>

                            <div class="book-meta">
                                <div><i class="fas fa-user-edit"></i> @item.BookAuthor</div>
                                <div><i class="fas fa-building"></i> @item.Bookpress</div>
                                <div><i class="fas fa-tag"></i> @item.Booksort</div>
                                <div><i class="fas fa-yen-sign"></i> @item.BookPrice.ToString("0.00")</div>
                            </div>

                            <div class="book-actions">
                                @Html.ActionLink("修改", "Edit", new { id = item.Id }, new { @class = "action-btn edit-btn" })
                                @Html.ActionLink("详细", "Details", new { id = item.Id }, new { @class = "action-btn detail-btn" })
                                @Html.ActionLink("删除", "Delete", new { id = item.Id }, new { @class = "action-btn delete-btn" })
                            </div>
                        </div>
                    </div>
                }
            </div>

            <!-- 分页控件 - 底部 -->
            <div class="pagination-container" style="justify-content:center">
                <div class="pagination">
                    @if (currentPage > 1)
                    {
                        <a href="@Url.Action("GetBookList", new { page = 1 })" class="page-link first"><i class="fas fa-angle-double-left"></i></a>
                        <a href="@Url.Action("GetBookList", new { page = currentPage - 1 })" class="page-link prev"><i class="fas fa-angle-left"></i></a>
                    }
                    else
                    {
                        <span class="page-link first disabled"><i class="fas fa-angle-double-left"></i></span>
                        <span class="page-link prev disabled"><i class="fas fa-angle-left"></i></span>
                    }

                    @for (int i = Math.Max(1, currentPage - 2); i <= Math.Min(totalPages, currentPage + 2); i++)
                    {
                        if (i == currentPage)
                        {
                            <span class="page-link active">@i</span>
                        }
                        else
                        {
                            <a href="@Url.Action("GetBookList", new { page = i })" class="page-link">@i</a>
                        }
                    }

                    @if (currentPage < totalPages)
                    {
                        <a href="@Url.Action("GetBookList", new { page = currentPage + 1 })" class="page-link next"><i class="fas fa-angle-right"></i></a>
                        <a href="@Url.Action("GetBookList", new { page = totalPages })" class="page-link last"><i class="fas fa-angle-double-right"></i></a>
                    }
                    else
                    {
                        <span class="page-link next disabled"><i class="fas fa-angle-right"></i></span>
                        <span class="page-link last disabled"><i class="fas fa-angle-double-right"></i></span>
                    }
                </div>
            </div>
        </div>

        <!-- 页脚 -->
        <div id="footer">
            <hr style="margin:20px 0px;" />
            广软智慧书城后台管理系统 - MVC架构 © @DateTime.Now.Year
        </div>
    </div>

    <script src="~/conjs/jquery-3.4.1.js"></script>
    <script src="~/conjs/bootstrap.js"></script>
</body>
</html>